/*
 * Created on 3-Dec-2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.mtdownload.download;

import java.io.Serializable;



/**
 * A class that holds the completed number of bytes for all the threads that are
 * in this download. We can have only ONE instance of it (created by the downloadmaster thread) 
 * @author sergiu
 */
class BytesCounter implements Serializable{
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 3257288041289889584L;
	private long completedBytes=0;
	private DownloadTask task;
	
	public BytesCounter(DownloadTask task){
		this.task=task;
	}
	
	public synchronized void updateCompletedBytes(int bytes){			
		completedBytes+=bytes;
		task.setCompletedBytes(completedBytes);
	}
	public synchronized long getCompletedBytes(){
		return completedBytes;
	}		
}
